home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-28 | 5.4 KB | 218 lines | [TEXT/MPS ] |
- /*
- File: DebuggingWindows.cp
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __DEBUGGINGGEAR__
- #include "DebuggingGear.h"
- #endif
-
- #ifndef __DEBUGSTREAM__
- #include "DebugStream.h"
- #endif
-
- #ifndef __DEBUGGINGWINDOWS__
- #include "DebuggingWindows.h"
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __TRANSCRIPTWINDOW__
- #include "TranscriptWindow.h"
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __STDIO__
- #include <stdio.h>
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- #ifndef __WRITELINEWINDOW__
- #include "WriteLineWindow.h"
- #endif
-
- /***********************************|****************************************/
-
- Boolean GetDefaultWindowInformation ( short dialogID, Boolean& visible, Rect & screenRect );
- Boolean RectOnScreen ( const Rect & rect );
-
- extern short gApplicationFile;
-
- /***********************************|****************************************/
-
- #pragma segment Initialize
- void InitializeDebuggingWindows()
- {
- Rect where;
- Boolean visible;
-
- #if 0
- WWInit (240, 80);
-
- // Initialize the debugging window stuff
- { short debugFont;
- Rect bounds;
- unsigned long currentTime;
-
- GetDateTime (¤tTime);
- SetRect (&bounds, 16, 40, 16+80*6+16, 40+32*12+16);
-
- GetFNum ("\pASCII Courier", &debugFont);
- if (debugFont == 0)
- GetFNum ("\pMonaco", &debugFont);
-
- Rect where;
- Boolean visible;
- if ( GetDefaultWindowInformation ( -1, visible, where ) && RectOnScreen ( where ) )
- WWNew ( & where, "\pBovineServer Log", true, visible, debugFont, 10 );
- else
- WWNew(&bounds, "\pBovineServer Debug", true, true, debugFont, 10);
-
- // Create a
- {
- DateTimeRec now;
- GetTime ( & now );
-
- Str255 logFileName;
-
- logFileName[0] = sprintf ( (char*) logFileName,
- "*BS Log %02d%02d%02d %02d%02d",
- now.year % 100,
- now.month, now.day,
- now.hour, now.minute ) - 1 ;
-
- extern short gBovineWorkingVRefNum;
- extern unsigned long gBovineWorkingDirID;
- unsigned long gBovineServerLogFileDirectory =
- CreateFolderIfItDoesntExist ( gBovineWorkingVRefNum, gBovineWorkingDirID, "\pBovineServer Logs" );
-
- WWRedirect (gBovineWorkingVRefNum, gBovineServerLogFileDirectory, logFileName );
-
- if ( keithFlag.Flag ( 24 ) )
- DeleteFilesInFolderOlderThan ( gBovineServerLogFileDirectory, gBovineServerLogFileDirectory, NowDateTime() - 3*60*60*24 );
- }
-
- // Make the debugging window font non-purgeable
- Handle fondHandle = GetResource ('FOND', debugFont);
- if (fondHandle)
- HNoPurge(fondHandle);
-
- Handle fontHandle = GetResource ('FONT', debugFont);
- if (fontHandle) HNoPurge(fontHandle);
-
- // Put the time we started into the debugging window
- keith <<
- "BLJ started at "
- << date << " " << time << endl;
- }
-
- #else
-
- extern TTranscriptWindow * gTranscriptWindow;
-
- if ( ! gTranscriptWindow )
- {
- gTranscriptWindow = new TTranscriptWindow ( 2000 );
- gTranscriptWindow->Show ();
- }
-
- // Initialize the debugging window stuff
- {
- Rect where;
- Boolean visible;
-
- // Create a name for the log window.
- {
- DateTimeRec now;
- GetTime ( & now );
-
- Str255 logFileName;
-
- logFileName[0] = sprintf ( (char*) logFileName,
- "*BS Log %02d%02d%02d %02d%02d",
- now.year % 100,
- now.month, now.day,
- now.hour, now.minute ) - 1 ;
-
- extern short gBovineWorkingVRefNum;
- extern unsigned long gBovineWorkingDirID;
- unsigned long gBovineServerLogFileDirectory =
- CreateFolderIfItDoesntExist ( gBovineWorkingVRefNum, gBovineWorkingDirID, "\pBovineServer Logs" );
-
- SetWTitle ( gTranscriptWindow->GetWindowPtr(), logFileName );
-
- gTranscriptWindow->Redirect (gBovineWorkingVRefNum, gBovineServerLogFileDirectory, logFileName );
-
- if ( keithFlag.Flag ( 24 ) )
- DeleteFilesInFolderOlderThan ( gBovineServerLogFileDirectory, gBovineServerLogFileDirectory, NowDateTime() - 3*60*60*24 );
- }
-
- // Put the time we started into the debugging window
- keith <<
- "BLJ started at " << date << " " << time << endl;
-
- // Get the 'vers' resource, so we can display it too
-
- short savedResFile = CurResFile();
- UseResFile(gApplicationFile);
- Handle versionResource = Get1Resource ('vers', 1);
- Str255 versionString = "\p, no version string";
- short nonReleaseRevNumber;
-
- if (versionResource)
- {
- HLock (versionResource);
- NumVersion *versionRec = (NumVersion *) *versionResource;
-
- char devCode = '?';
- nonReleaseRevNumber = 10 * (versionRec->nonRelRev >> 4) + (versionRec->nonRelRev & 0xF);
- switch (versionRec->stage)
- {
- case developStage: devCode = 'd'; break;
- case alphaStage: devCode = 'a'; break;
- case betaStage: devCode = 'b'; break;
- case finalStage: devCode = 'f'; break;
- }
-
- versionString[0] = sprintf ((char *) versionString, "* version resource %d.%d.%d%c%d",
- versionRec->majorRev,
- versionRec->minorAndBugRev >> 4,
- versionRec->minorAndBugRev & 0xF,
- devCode,
- nonReleaseRevNumber)
- - 1;
- ReleaseResource (versionResource);
- }
- UseResFile (savedResFile);
- keith << "Application name is " << LMGetCurApName() << versionString << endl;
- }
-
- #endif
- }
-
- /***********************************|****************************************/
-